package com.tuling.jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yinpeng on 2021/01/31
 */
public class JvmTest2 {

    List<Object> barrierSet = new ArrayList<>();

    /**
     * jvm内部引用变更调用的函数
     * */
    void changeRef(Object ref,Object val){
        // 写前屏障调用
        update_barrier_set_pre(ref);
        ref = val;
        // 写后屏障调用
        update_barrier_set(ref);
    }

    /**
     * 写前屏障
     * */
    void update_barrier_set_pre(Object ref){
        barrierSet.add(ref);
    }

    /**
     * 写后屏障
     * */
    void update_barrier_set(Object ref){
        barrierSet.add(ref);
    }
}
